﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI.Selection;

namespace YArchitech.Revit
{
	public class PipeFilterBySystemName : ISelectionFilter
	{
		public PipeFilterBySystemName(string systemName)
		{
			this.sName = systemName;
		}

		public bool AllowElement(Element elem)
		{
			if (elem is Pipe)
			{
				Pipe pipe = elem as Pipe;
				if (pipe == null)
				{
					return false;
				}
				if (pipe.GetSystemName().Equals(this.sName))
				{
					return true;
				}
			}
			if (elem is FamilyInstance)
			{
				BuiltInCategory integerValue = elem.Category.Id.IntegerValue;
				if (integerValue != -2008055 && integerValue != -2008049)
				{
					return false;
				}
				if ((elem as FamilyInstance).GetSystemName().Equals(this.sName))
				{
					return true;
				}
			}
			return false;
		}

		public bool AllowReference(Reference reference, XYZ position)
		{
			return false;
		}

		private string sName = "";
	}
}
